<!--巡检订单详情-->
<template>
  <div class="main">
    <div class="info-container">
      <div class="info-container_body">
        <el-form ref="refFrom" label-position="top" class="demo">
          <div class="form-section">
            <div class="form-section_title">摘要信息</div>
            <el-form ref="refFrom" label-position="top">
              <el-row>
                <el-col :span="5">
                  <el-form-item label="区域"> {{item.regionCode}}</el-form-item>
                </el-col>
                <el-col :span="5">
                  <el-form-item label="处理状态">
                    <el-tag v-if="item.status == 1" type="warning">未处理</el-tag>
                    <el-tag v-else-if="item.status == 2" type="primary">处理中</el-tag>
                    <el-tag v-else-if="item.status == 3" type="success">已处理</el-tag>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
          <div class="form-section">
            <div class="form-section_title">巡检信息</div>

            <vxe-table ref="tableRef" :data="item.items" v-loading="loading">
              <vxe-table-column :resizable="true" type="seq" title="序号" width="80" sortable> </vxe-table-column>
              <vxe-table-column :resizable="true" field="deviceId" title="设备编号" sortable> </vxe-table-column>
              <vxe-table-column :resizable="true" field="deviceType" title="设备类型" sortable>
                <template #default="{ row }">
                  {{$common.marchType(row.deviceType,dict.device_type)}}
                </template>
              </vxe-table-column>
              <vxe-table-column :resizable="true" field="placeName" title="站房名称" sortable> </vxe-table-column>
            </vxe-table>
          </div>
          <div class="form-section">
            <div class="form-section_title">补充说明</div>
            {{item.remarks}}
          </div>
          <div class="form-section">
            <div class="form-section_title">处理信息</div>

            <el-form ref="refFrom" label-position="top">
              <el-row>
                <el-col :span="10">
                  <el-form-item label="处理人">
                    {{item.processUser}}
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item label="完成时间">
                    {{item.finishTime}}
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </el-form>
      </div>

      <div class="info-container_footer">
        <el-button @click="handleCancel">取消</el-button>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineAsyncComponent } from 'vue';
import { getMaintenance } from '@/api/station/maintenance/index';

import common from '@/utils/common.ts';

export default {
  components: {},
  props: {
    data: {}
  },
  computed: {},
  data() {
    return {
      loading: false,
      active: 1,
      users: [],
      placeType: [
        { label: '站房', value: '1' },
        { label: '酒店', value: '2' }
      ],
      causeType: [
        { label: '设备故障', value: '1' },
        { label: '异常终端', value: '2' }
      ],
      item: {},
      proxy: {}
    };
  },
  mounted() {
    const { proxy } = getCurrentInstance() as ComponentInternalInstance;
    this.proxy = proxy;

    this.dict = toRefs<any>(this.proxy?.useDict('room_position', 'device_type'));

    const route = useRoute();
    this.item.id = route.query.id;
    this.init();
  },
  methods: {
    init() {
      let id = this.item.id;
      this.get(id);
    },

    get(id) {
      this.loading = true;
      getMaintenance(id).then((res) => {
        this.loading = false;
        if (res.code == 200) {
          this.item = res.data;
        } else {
          ElMessage.error(res.msg);
        }
      });
    },

    handleCancel() {
      this.proxy?.$tab.closePage();
    },

    /**
     * 匹配结果
     */
    marchType(value, types) {
      for (let i = 0; i < types.length; i++) {
        let type = types[i];
        if (type.value == value) return type.label;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.main {
  height: 100%;
  padding: 10px;

  .myPager {
    width: 100%;
    height: 50px;
    text-align: right;
  }
}

.info-container {
  height: calc(100% - 50px);
}
</style>
<style>
</style>